﻿using System;
using System.Windows.Controls;
using System.Windows.Data;

namespace NeuroForecast
{
    /// <summary>
    /// Interaction logic for SourceListItem.xaml
    /// </summary>
    public partial class SourceListItem
    {
        public int ID { set; get; }
        public string Caption
        {
            set { tb_Name.Text = value; }
            get { return tb_Name.Text; } 
        }
        public string Source 
        {
            set { tb_Source.Text = value; }
            get { return tb_Source.Text; }
        }
        public bool? IsChecked
        {
            set { cb_InUse.IsChecked = value; }
            get { return cb_InUse.IsChecked; }
        }
        public ListBox Owner 
        {
            set
            {
                Binding bind = new Binding("ActualWidth");
                bind.Source = value;
                bind.Converter = new MyConverter();
                SetBinding(WidthProperty, bind);
            }
        }
        public int ColumnNumber { set; get; }

        public SourceListItem()
        {
            InitializeComponent();
        }

        public class MyConverter : IValueConverter
        {
            public object Convert(object values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                return (double)values - 5;
            }

            public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
            {
                return (double)value - 5;
            }
        }
    }
}
